package Lee_code;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author blh
 * 用最少数量的箭引爆气球
 * @date 2024年11月01日 8:53
 */
public class Lee_452_111_2 {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, Comparator.comparingInt(a -> a[0]));
        int result = 1;
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] > points[i - 1][1]) {
                result++;

            } else {
                points[i][1] = Math.min(points[i][1], points[i - 1][1]);
            }
        }
        return result;
    }
}
